﻿using Microsoft.EntityFrameworkCore;
using Model;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MESMian.ValueGenerators;

namespace MESMian.EntityMapping
{
    public class ProductSpecsMapping : IEntityTypeConfiguration<ProductSpecs>
    {
        public void Configure(EntityTypeBuilder<ProductSpecs> builder)
        {
            builder.HasKey(p => p.ProductSpecId);

            builder.Property(p => p.ProductSpecName)
                .IsRequired()
                .HasColumnType("varchar(30)");

            builder.Property(p => p.Status)
                .HasColumnType("int")
                .HasDefaultValue(0)
                .IsRequired();

            builder.Property(p => p.CreateUserId)
                .HasColumnType("int")
                .IsRequired();

            builder.Property(p => p.CreateTime)
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                //.HasValueGenerator<CreatedDateGenerator>()
                .IsRequired()
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(p => p.LastUpdateUserId)
                .HasColumnType("int");

            builder.Property(p => p.LastUpdateTime)
                .HasColumnType("dateTime");

        }
    }
}
